//
//  ShoppingViewController.m
//  BakeCenter
//
//  Created by lanou3g on 15/9/18.
//  Copyright (c) 2015年 Baked. All rights reserved.
//

#import "ShoppingViewController.h"
#import "ShoppingWebView.h"
@interface ShoppingViewController ()<UIWebViewDelegate>
@property (nonatomic, strong) ShoppingWebView *webView;
@end

@implementation ShoppingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
     self.webView = [[ShoppingWebView alloc] initWithFrame:kScreenBounds];
    [self.view addSubview:self.webView];

    UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithTitle:@"后退" style:(UIBarButtonItemStyleDone) target:self action:@selector(goBack:)];
    self.navigationItem.leftBarButtonItem = leftButton;
    
    UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"前进" style:(UIBarButtonItemStyleDone) target:self action:@selector(goForward:)];
    self.navigationItem.rightBarButtonItem = rightButton;
    
    //添加轻扫手势
    UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(goBackWithGesture:)];
    [self.webView addGestureRecognizer:swipeGesture];
    

   
    
    
    
}


-(void)goBackWithGesture:(UISwipeGestureRecognizer *)Gesture{
    
    if (Gesture.direction == UISwipeGestureRecognizerDirectionLeft) {
        [self.webView goForward];
    }else if (Gesture.direction == UISwipeGestureRecognizerDirectionRight){
        [self.webView goBack];
    }
    
}


-(void)goBack:(UIBarButtonItem *)leftButton{

    [self.webView goBack];
}

-(void)goForward:(UIBarButtonItem *)goForward{
    
    [self.webView goForward];
}

//完成加载时执行
-(void)webViewDidFinishLoad:(UIWebView *)webView{
    
    
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
